<!--质押金管理-->
<template>
  <div>
    <f-search-form :more='true' @searchHandler='searchHandler' :tableObj='$refs.table'>
      <f-search-form-item label='业务员' name='saleManName'/>
      <f-search-form-item label='开始日期' type='date' name='beginDate'  />
      <f-search-form-item label='结束日期' type='date' name='endDate'/>
    </f-search-form>
    <f-table ref='table' rowKey='saleManBalanceId' :columns='columns' :showMultipleBtn='false' :multiple='true' :operator='operator'  :params='queryParam' :api='api.bsmb' handler='saleBalanceTab2PageListHandler'>
        <span slot='depositState' slot-scope='text, record, index'>
            <a-tag color='pink' v-if='text==0'>未提交</a-tag>
            <a-tag color='#87d068' v-if='text==1'>已认款</a-tag>
            <a-tag color='#f50' v-if='text==2'>已退款</a-tag>
        </span>
      <span slot='action' slot-scope='text, record'>
          <template>
            <a @click="$refs.drawer.showDrawer(record,'form1')">查看</a>
            <a-divider type='vertical' />
            <a-dropdown>
            <a class='ant-dropdown-link'>更多<a-icon type='down' /></a>
            <a-menu slot='overlay'>
              <a-menu-item v-if='record.depositState==0'>
                <a href='javascript:;' @click='$refs.table.del(record)'>删除</a>
              </a-menu-item>
              <a-menu-item v-if='record.orderState!=0'>
                 <a href='javascript:;' @click='$refs.amount.showDrawer(record)'>退款</a>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
          </template>

        </span>
    </f-table>
    <amount-drawer ref='amount'></amount-drawer>
    <print-modal ref='printModal'></print-modal>
  </div>
</template>
<script>
import ProcessImage from "../../flowable/process/process_image"
import api from "../js/api"
import PrintModal from "@/views/module/business/order/print/print_modal"

export default {
  name: "Tab2",
  components: {
    ProcessImage,
    PrintModal
  },
  data() {
    let me = this
    //操作按钮
    let operator = []
   
    operator.push({
      name: "删除",
      icon: "delete",
      batch: true,
      handler: function(table) {
        table.remove()
      }
    })
    return {
      api: Object.assign(api, this.api),
      processImageVisible: false,
      //列表初始化查询参数
      queryParam: {},
      // 表头
      columns: [
        {
          title: "序号",
          width: "60px",
          align: "center",
          customRender: (text, record, index) => index + 1
        },
        {
          title: "订单编号",
          align: "center",
          width: "100px",
          ellipsis: true,
          dataIndex: "orderNo"
        },
        {
          title: "发货日期",
          align: "center",
          width: "100px",
          ellipsis: true,
          dataIndex: "sendDate"
        },
        {
          title: "商品名称",
          align: "center",
          width: "100px",
          ellipsis: true,
          dataIndex: "drugsName"
        },
        {
          title: "商品规格",
          align: "center",
          width: "100px",
          dataIndex: "drugsSpec"
        }, {
          title: "销售单价",
          align: "center",
          width: "80px",
          dataIndex: "salePrice"
        },{
          title: "数量",
          align: "center",
          width: "80px",
          dataIndex: "saleNum"
        },
        {
          title: "抵扣金额",
          align: "center",
          width: "80px",
          dataIndex: "amount"
        },
        {
          title: "操作",
          align: "center",
          width: "120px",
          dataIndex: "action",
          fixed: "right",
          scopedSlots: { customRender: "action" }
        }
      ],
      operator: operator
    }
  },
  created() {
  },
  methods: {
    onLoad() {
      this.$refs.table.refresh()
    },
    processImg(order) {
      this.processInstanceId = order.processInstanceId
      this.processImageVisible = true
    },
    //重新提交
    completeTask(deposit) {
      this.http.confirm(this, {
        content: "确认提交审批吗?",
        url: api.tasktodo.complete,
        requestBody: true,
        data: {
          taskId: deposit.taskId
        },
        success: function(me, data) {
          me.$refs.table.refresh()
        }
      })
    },
    //打印退款单
    printPayment(record) {
      this.$refs["printModal"].open(record.depositId, 2, "Other")
    },
    startProcess(deposit) {
      this.http.confirm(this, {
        content: "确认提交审批吗?",
        url: api.processInstance.start,
        requestBody: true,
        data: {
          handlerName: "depositStartProcessHandler",
          businessKey: deposit.depositId
        },
        success: function(me, data) {
          me.$refs.table.refresh()
        }
      })
    }
  }
}
</script>
